# from redis import StrictRedis
from os.path import join, dirname, realpath
from os import environ


class Config:
    """
    配置类中配置项必须大写
    """
    # with current_app.app_context():
    UPLOAD_PATH = join(dirname(realpath(__file__)), '../static/uploads/')

    CKEDITOR_FILE_UPLOADER = 'upload'
    CKEDITOR_SERVE_LOCAL = True
    CKEDITOR_HEIGHT = 400

    # 配置数据库的连接 /var/run/mysqld/mysqld.sock
    SQLALCHEMY_DATABASE_URI = "mysql+mysqlconnector://root:pzzrudlf@127.0.0.1/flask_blog2?unix_socket=/tmp/mysql.sock"
    # 配置数据库内容在更新时自动提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = False
    # 动态追踪修改设置，如未设置只会提示警告
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 查询时会显示原始SQL语句
    SQLALCHEMY_ECHO = False

    SECRET_KEY = environ.get('SECRET_KEY') or 'rtrzexkkcfjefa'

    # REDIS_HOST = '127.0.0.1'
    # REDIS_PORT = 6379
    TOKEN_EXPIRATION = 30 * 24 * 3600

    # flask_session的配置信息
    # SESSION_TYPE = "redis"  # 指定 session 保存到 redis 中
    # SESSION_USE_SIGNER = True  # 让 cookie 中的 session_id 被加密签名处理
    # SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=1)  # 使用 redis 的实例
    # PERMANENT_SESSION_LIFETIME = 24 * 60 * 60  # session 的有效期，单位是秒
